var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
import { defineComponent, ref, computed, onMounted, h, watch, nextTick, onBeforeUnmount, resolveComponent, createElementBlock, openBlock, createElementVNode, createCommentVNode, withModifiers, toDisplayString, normalizeStyle, createVNode, withDirectives, Fragment, renderList, createBlock, vShow, mergeModels, useModel, withCtx, unref, createTextVNode } from "vue";
import { ElIcon, ElSelect, ElOption, ElInput, ElMessage, ElMessageBox } from "element-plus";
import { CircleClose, CircleCheck, Plus, Minus, Search } from "@element-plus/icons-vue";
import { defineStore } from "pinia";
const _sfc_main$5 = defineComponent({
  name: "NodeValue",
  props: {
    data: {
      type: Object,
      required: true
    },
    readonly: {
      type: Boolean,
      required: true
    }
  },
  setup(props, context) {
    const isHasFocus = ref(false);
    const validText = ref("");
    const checkText = ref("");
    const validTypeArr = ["Integer", "BitString", "NumericString", "Ia5string", "OctetString", "String"];
    const otherProps = computed(() => {
      return props.data.bitArray ? props.data.bitArray.map((x) => x ? 1 : 0).join("") : "";
    });
    const formValid = (data) => {
      if (data.isRequired && data.value === "") {
        validText.value = "字段必填";
        return;
      }
      if (data.controlType === "Integer") {
        const { minInclusive, maxInclusive, value } = data;
        if (!minInclusive && !maxInclusive) {
          checkText.value = validText.value = "";
          return;
        }
        if (Number(value) < minInclusive) {
          validText.value = `最小值为${minInclusive}`;
          return;
        }
        if (Number(value) > maxInclusive) {
          validText.value = `最大值为${maxInclusive}`;
          return;
        }
      } else if (data.controlType === "BitString") {
        const { Length } = data;
        checkText.value = `长度为${Length}的二进制数`;
        if (otherProps.value.length !== Length) {
          validText.value = `长度应为${Length}`;
          return;
        }
      }
      validText.value = "";
    };
    const updateEmit = () => {
      if (validText.value === "") {
        context.emit("updateForm", props.data);
      }
    };
    const publicEvent = {
      onfocus: () => {
        isHasFocus.value = true;
      },
      onblur: () => {
        isHasFocus.value = false;
      }
    };
    onMounted(() => {
    });
    const strategy = {
      Integer: (data) => {
        const { value, isReadOnly: disabled } = data;
        return h(ElInput, {
          class: ["int-input", "el-input"],
          // 保持原有类名 + 组件基础类
          modelValue: value,
          // 双向绑定值
          readonly: props.readonly,
          disabled,
          "onUpdate:modelValue": (val) => {
            data.value = val;
            formValid(data);
          },
          onChange: (val) => {
            if (!value) return;
            data.value = parseFloat(val);
            updateEmit();
          },
          ...publicEvent
        });
      },
      Ia5string: (data) => {
        const { value, minLength, isReadOnly: disabled } = data;
        return h(ElInput, {
          class: ["int-input", "el-input"],
          // 保持原有类名 + 组件基础类
          modelValue: value,
          // 双向绑定值
          readonly: props.readonly,
          "onUpdate:modelValue": (val) => {
            data.value = val;
            formValid(data);
          },
          onChange: () => {
            updateEmit();
          },
          ...publicEvent
        });
      },
      String: (data) => {
        const { value, minLength, isReadOnly: disabled } = data;
        return h(ElInput, {
          class: ["int-input", "el-input"],
          // 保持原有类名 + 组件基础类
          modelValue: value,
          // 双向绑定值
          readonly: props.readonly,
          "onUpdate:modelValue": (val) => {
            data.value = val;
            formValid(data);
          },
          onChange: () => {
            updateEmit();
          },
          ...publicEvent
        });
      },
      OctetString: (data) => {
        const { value, minLength, isReadOnly: disabled } = data;
        return h(ElInput, {
          class: ["int-input", "el-input"],
          modelValue: value,
          // 双向绑定值
          readonly: props.readonly,
          attrs: { minlength: minLength, readonly: props.readonly },
          "onUpdate:modelValue": (val) => {
            data.value = val;
            formValid(data);
          },
          onChange: (val) => {
            const is16Hex = /^[\-A-Fa-f0-9\s]*$/.test(val);
            if (is16Hex) {
              const newValue = value !== "" ? String(value).replace(/\s+/g, "").match(new RegExp("[^\\n]{1,2}", "g")).join(" ") : "";
              data.value = newValue;
              formValid(data);
              updateEmit();
            }
          }
        });
      },
      // NumericString: (data: nodeItem) => {
      //   const { Value: value, MinLength, IsReadOnly: disabled } = data;
      //   return h("el-input", {
      //     class: "int-input",
      //     props: { value, disabled },
      //     attrs: { minlength: MinLength, readonly: props.readonly },
      //     on: {
      //       input: (value: string) => {
      //         const isNumber = /^[\.\-0-9]*$/.test(value);
      //         if (isNumber) {
      //           data.Value = value;
      //           formValid(data);
      //         }
      //       },
      //       ...publicEvent,
      //     },
      //   });
      // },
      // BitString: (data: nodeItem) => {
      //   const { IsReadOnly: disabled } = data;
      //   const { value } = otherProps;
      //   return h("el-input", {
      //     class: "int-input",
      //     props: { otherProps.value.value, disabled },
      //     attrs: { readonly: props.readonly },
      //     on: {
      //       input: (value: string) => {
      //         const isBinary = /^[0|1]*$/.test(value);
      //         if (isBinary) {
      //           data.OtherProps = value;
      //           formValid(data);
      //         }
      //       },
      //       change: (value: string) => {
      //         data.BitArray = value.split("").map(x => !!Number(x));
      //       },
      //       ...publicEvent,
      //     },
      //   });
      // },
      Enum: (data) => {
        const { value, constraint, isReadOnly: disabled } = data;
        const options = [];
        constraint == null ? void 0 : constraint.forEach((optionValue) => {
          options.push({ label: optionValue, value: optionValue });
        });
        return h(
          ElSelect,
          {
            class: "custom-el-select",
            // 添加自定义类名
            modelValue: data.value,
            "onUpdate:modelValue": (val) => {
              data.value = val;
            },
            onChange: () => {
              updateEmit();
            },
            size: "small"
          },
          [
            ...options.map(
              (option) => h(ElOption, {
                key: option.value,
                label: option.label,
                value: option.value
              })
            )
          ]
        );
      },
      // Choice: (data: nodeItem) => {
      //   const { Value: value, Constraint, IsReadOnly: disabled } = data;
      //   const optionsArr = Constraint.map(value => {
      //     if (typeof value === "string") return;
      //     return h("el-option", { props: { label: value.Name, value } });
      //   });
      //   return h(
      //     "el-select",
      //     {
      //       class: "enum-select",
      //       props: { value, valueKey: "Name", placeholder: " ", disabled: disabled || props.readonly },
      //       on: {
      //         input: (value: string) => {
      //           data.Value = value;
      //         },
      //       },
      //     },
      //     [optionsArr],
      //   );
      // },
      Boolean: (data) => {
        const options = [
          { label: "是", value: true },
          { label: "否", value: false }
        ];
        return h(
          ElSelect,
          {
            class: "custom-el-select",
            // 添加自定义类名
            modelValue: data.value,
            "onUpdate:modelValue": (val) => {
              data.value = val;
            },
            onChange: () => {
              updateEmit();
            },
            size: "small"
          },
          [
            ...options.map(
              (option) => h(ElOption, {
                label: option.label,
                value: option.value
              })
            )
          ]
        );
      },
      Sequence: () => {
        return h("div", {}, "");
      },
      SequenceList: (data) => {
        const max = 9999;
        const min = 0;
        const len = data.child && data.child.length;
        const elementName = "成员";
        return h("div", { class: "sequence-list-value" }, [
          h(
            "div",
            {
              class: "btn-icon"
            },
            [
              h(
                ElIcon,
                {
                  class: `el-icon-plus ${len < max ? "" : "gray"}`,
                  onClick: () => {
                    if (len < max) {
                      const addRow = data.elementForm;
                      const count = data.child ? data.child.length + 1 : 1;
                      if (addRow) {
                        addRow.name = `${elementName}(${count})`;
                      }
                      data.child.push(JSON.parse(JSON.stringify(addRow)));
                      updateEmit();
                    }
                  }
                },
                [h(Plus)]
              ),
              h(
                ElIcon,
                {
                  class: `el-icon-minus ${len > min ? "" : "gray"}`,
                  onClick: () => {
                    if (len > min) {
                      data.child.pop();
                      updateEmit();
                    }
                  }
                },
                [h(Minus)]
              )
            ]
          )
          // h("span", { class: "valid-text" }, validText),
        ]);
      },
      // 其他控件类型的渲染逻辑...
      default: (data) => {
        return h("div", {}, `未定义的控件类型: ${data.controlType}`);
      }
    };
    formValid(props.data);
    return () => {
      return h(
        "div",
        {
          class: {
            "node-value": true,
            "node-valid-error": validText.value
          }
        },
        [
          (strategy[props.data.controlType] || strategy.default)(props.data),
          validTypeArr.includes(props.data.controlType) && h("span", { class: "valid-icon" }, [
            [
              validText.value ? h(ElIcon, { color: "red", size: 16 }, [h(CircleClose)]) : isHasFocus.value && !props.readonly && h(ElIcon, { color: "#67c23a", size: 16 }, [h(CircleCheck)])
            ],
            isHasFocus.value && validText.value && h("div", { class: "valid-tips err" }, validText.value),
            !validText.value && !props.readonly && isHasFocus.value && checkText.value && h("div", { class: "valid-tips" }, checkText.value)
          ])
        ]
      );
    };
  }
});
const _export_sfc$1 = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const NodeValue = /* @__PURE__ */ _export_sfc$1(_sfc_main$5, [["__scopeId", "data-v-a8b820df"]]);
const systolicIcon = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\r\n<g id="HTSCIT_&#229;&#177;&#149;&#229;&#188;&#128; 2">\r\n<path id="Vector" d="M6.27673 6.28553H17.7233V17.7409H6.27673V6.28553ZM5 5.00881V19H19V5H5V5.00881Z" fill="currentColor"/>\r\n<path id="Vector_2" d="M8 13V11H16V13H8Z" fill="#3a6ef6"/>\r\n</g>\r\n</svg>\r\n';
const expandIcon = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\r\n<g id="HTSCIT_&#229;&#177;&#149;&#229;&#188;&#128; 1">\r\n<path id="Vector" d="M6.27673 6.28553H17.7233V17.7409H6.27673V6.28553ZM5 5.00881V19H19V5H5V5.00881Z" fill="currentColor"/>\r\n<path id="Union" fill-rule="evenodd" clip-rule="evenodd" d="M12.5471 8.1925H11.4528V11.4642H8.18115V12.5585H11.4528V15.8302H12.5471V12.5585H15.8189V11.4642H12.5471V8.1925Z" fill="#3a6ef6"/>\r\n</g>\r\n</svg>\r\n';
const toolIcon = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\r\n<path d="M13.9498 6C14.8591 6 15.699 6.29966 16.3746 6.80641L15.1183 8.06172L13.892 9.28926L14.7099 10.1078L17.1925 7.62438C17.7138 8.32091 17.997 9.16685 18 10.0369C18.003 10.9069 17.7257 11.7548 17.2093 12.4549C16.6928 13.1551 15.9646 13.6702 15.1325 13.9241C14.3004 14.178 13.4087 14.1571 12.5894 13.8645L8.98345 17.4702C8.82338 17.6359 8.6319 17.7682 8.42019 17.8591C8.20848 17.9501 7.98077 17.9979 7.75036 17.9999C7.51995 18.0019 7.29145 17.958 7.07819 17.8708C6.86493 17.7835 6.67118 17.6546 6.50825 17.4917C6.34532 17.3288 6.21647 17.135 6.12922 16.9217C6.04197 16.7084 5.99806 16.4799 6.00007 16.2495C6.00207 16.019 6.04994 15.7913 6.14088 15.5796C6.23183 15.3678 6.36402 15.1763 6.52976 15.0163L10.1351 11.41C9.9171 10.7988 9.84914 10.1442 9.93696 9.5013C10.0248 8.85838 10.2658 8.24598 10.6397 7.71569C11.0137 7.1854 11.5095 6.75274 12.0856 6.45416C12.6616 6.15558 13.301 5.99982 13.9498 6Z" fill="currentColor"/>\r\n</svg>\r\n';
const _sfc_main$4 = defineComponent({
  name: "NodeItem",
  components: {
    NodeValue
  },
  props: {
    data: {
      type: Object,
      required: true
    },
    w: {
      type: Number,
      required: true
    },
    readonly: {
      type: Boolean,
      required: true
    }
  },
  setup(props, { emit }) {
    const isExpand = ref(props.data.isExpand !== false);
    const isChildren = computed(() => {
      return props.data.child && props.data.child.length > 0;
    });
    const handleUpdate = (data) => {
      emit("updateForm", data);
    };
    return {
      isExpand,
      isChildren,
      handleUpdate,
      systolicIcon,
      expandIcon,
      toolIcon
    };
  }
});
const _hoisted_1$2 = { class: "node-view" };
const _hoisted_2$2 = { class: "node-item" };
const _hoisted_3$1 = { class: "left-item" };
const _hoisted_4 = { class: "icon-view" };
const _hoisted_5 = ["innerHTML"];
const _hoisted_6 = ["innerHTML"];
const _hoisted_7 = { class: "label-view" };
const _hoisted_8 = {
  key: 0,
  class: "node-children"
};
const _hoisted_9 = {
  key: 1,
  class: "node-children"
};
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_NodeValue = resolveComponent("NodeValue");
  const _component_NodeItem = resolveComponent("NodeItem", true);
  return openBlock(), createElementBlock("div", _hoisted_1$2, [
    createElementVNode("div", _hoisted_2$2, [
      createElementVNode("div", _hoisted_3$1, [
        createElementVNode("div", _hoisted_4, [
          _ctx.isChildren ? (openBlock(), createElementBlock("span", {
            key: 0,
            class: "ex-icon force-svg-16",
            innerHTML: _ctx.isExpand ? _ctx.systolicIcon : _ctx.expandIcon,
            onClick: _cache[0] || (_cache[0] = withModifiers(($event) => _ctx.isExpand = !_ctx.isExpand, ["stop"]))
          }, null, 8, _hoisted_5)) : (openBlock(), createElementBlock("span", {
            key: 1,
            class: "icon",
            innerHTML: _ctx.toolIcon
          }, null, 8, _hoisted_6))
        ]),
        createElementVNode("div", _hoisted_7, toDisplayString(_ctx.data.name), 1)
      ]),
      createElementVNode("div", {
        class: "right-item",
        style: normalizeStyle({ width: _ctx.w ? `${_ctx.w / 2}px` : "" })
      }, [
        createVNode(_component_NodeValue, {
          data: _ctx.data,
          readonly: _ctx.readonly,
          onUpdateForm: _ctx.handleUpdate
        }, null, 8, ["data", "readonly", "onUpdateForm"])
      ], 4)
    ]),
    _ctx.isChildren ? (openBlock(), createElementBlock("div", _hoisted_8, [
      withDirectives(createElementVNode("div", null, [
        (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data.child, (x, i) => {
          return openBlock(), createBlock(_component_NodeItem, {
            key: i,
            data: x,
            w: _ctx.w,
            readonly: _ctx.readonly,
            onUpdateForm: _ctx.handleUpdate
          }, null, 8, ["data", "w", "readonly", "onUpdateForm"]);
        }), 128))
      ], 512), [
        [vShow, _ctx.isExpand]
      ])
    ])) : createCommentVNode("", true),
    _ctx.data.controlType === "Choice" && _ctx.data.value ? (openBlock(), createElementBlock("div", _hoisted_9, [
      (openBlock(true), createElementBlock(Fragment, null, renderList([_ctx.data.value], (x, i) => {
        return openBlock(), createBlock(_component_NodeItem, {
          key: i,
          data: x,
          w: _ctx.w,
          readonly: _ctx.readonly,
          onUpdateForm: _ctx.handleUpdate
        }, null, 8, ["data", "w", "readonly", "onUpdateForm"]);
      }), 128))
    ])) : createCommentVNode("", true)
  ]);
}
const NodeItem = /* @__PURE__ */ _export_sfc$1(_sfc_main$4, [["render", _sfc_render$1], ["__scopeId", "data-v-49690e0a"]]);
defineComponent({
  name: "NodeTree",
  components: {
    NodeItem
  },
  props: {
    data: {
      type: Array,
      required: true
    },
    isHideHeader: {
      type: Boolean,
      default: false
    },
    readonly: {
      type: Boolean,
      default: false
    },
    isLoading: {
      type: Boolean,
      default: false
    }
  },
  setup(props, { emit }) {
    const treeTbodyW = ref(0);
    const treeTbody = ref(null);
    const scrollbar = ref(null);
    watch(
      () => props.data.length,
      () => {
        nextTick(() => {
          updateTreeTbodyWidth();
        });
      }
    );
    const updateTreeTbodyWidth = () => {
      if (treeTbody.value) {
        treeTbodyW.value = treeTbody.value.offsetWidth;
      }
    };
    const handleResize = () => {
      updateTreeTbodyWidth();
    };
    onMounted(() => {
      window.addEventListener("resize", handleResize);
    });
    onBeforeUnmount(() => {
      window.removeEventListener("resize", handleResize);
    });
    const handleUpdate = (data) => {
      emit("updateForm", data);
    };
    return {
      treeTbodyW,
      treeTbody,
      scrollbar,
      handleUpdate
    };
  }
});
const SEND_USER_CMD_KEY = "send-user-cmd";
const GET_USER_DATA_KEY = "get-user-data";
const useUserStore = defineStore("userInjection", () => {
  const sendUserCmd = ref(null);
  const setInjections = (injections) => {
    if (injections.sendUserCmd) {
      sendUserCmd.value = injections.sendUserCmd;
    }
  };
  return { sendUserCmd, setInjections };
});
function createCommand(moduleId, fixedParams) {
  return async function(data, params, config2 = {}) {
    const userStore = useUserStore();
    const sendUserCmd = userStore.sendUserCmd;
    if (!sendUserCmd) {
      throw new Error("sendUserCmd 未在 Pinia 中初始化，请检查插件根组件是否正常挂载");
    }
    const commandPayload = {
      moduleId,
      fixedParams,
      data,
      params: { ...fixedParams, ...params },
      config: config2
    };
    const result = await sendUserCmd("execute", commandPayload);
    return result;
  };
}
const moudleType = "UserForm";
const getUsersByCondition = createCommand(moudleType, { commandName: "GetUsersByCondition" });
const addUser = createCommand(moudleType, { commandName: "AddUser" });
const updateUser = createCommand(moudleType, { commandName: "UpdateUser" });
const deleteUser = createCommand(moudleType, { commandName: "DeleteUser" });
const getRoles = createCommand(moudleType, { commandName: "GetRoles" });
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  ...{
    name: "FormDialog"
  },
  __name: "AddDialog",
  props: /* @__PURE__ */ mergeModels({
    detail: { default: () => ({}) },
    roles: { default: () => [] }
  }, {
    "modelValue": { type: Boolean },
    "modelModifiers": {}
  }),
  emits: /* @__PURE__ */ mergeModels(["update"], ["update:modelValue"]),
  setup(__props, { emit: __emit }) {
    const emits = __emit;
    const visible = useModel(__props, "modelValue");
    const props = __props;
    const title = computed(() => {
      var _a;
      return ((_a = props.detail) == null ? void 0 : _a.id) ? "编辑用户" : "新增用户";
    });
    const state = ref("");
    const formData = ref({});
    const formView = ref(null);
    const config2 = [
      { label: "用户名", prop: "name", required: true },
      { label: "账号", prop: "account", required: true },
      {
        label: "密码",
        prop: "password",
        inputType: "password",
        required: true,
        placeholder: "大小写字母+数字+特殊符号8位以上",
        rules: [
          {
            validator: (_, value, callback) => {
              const pattrn = /^(?![A-Za-z0-9]+$)(?![a-z0-9\W]+$)(?![A-Za-z\W]+$)(?![A-Z0-9\W]+$)[a-zA-Z0-9\W]{8,}$/;
              if (value && !pattrn.test(value)) {
                callback(new Error("请输入正确的密码格式！"));
              } else {
                callback();
              }
            },
            trigger: "blur"
          }
        ]
      },
      {
        label: "确认密码",
        prop: "password2",
        inputType: "password",
        required: true,
        placeholder: "请再次输入密码",
        rules: [
          {
            validator: (_, value, callback) => {
              var _a;
              const formVal = (_a = formView.value) == null ? void 0 : _a.data;
              console.log(formVal);
              if (value !== (formVal == null ? void 0 : formVal.password)) {
                callback(new Error("两次输入密码不一致"));
              } else {
                callback();
              }
            },
            trigger: "blur"
          }
        ]
      },
      { label: "角色", prop: "role", type: "select", options: [], required: true }
    ];
    const init = async () => {
      var _a, _b, _c, _d, _e;
      const id = (_a = props.detail) == null ? void 0 : _a.id;
      id && getInfo();
      (_b = formView.value) == null ? void 0 : _b.update("role", "options", props.roles);
      (_c = formView.value) == null ? void 0 : _c.update("password", "required", !id);
      (_d = formView.value) == null ? void 0 : _d.update("password2", "required", !id);
      (_e = formView.value) == null ? void 0 : _e.update("account", "disabled", !!id);
    };
    const getInfo = async () => {
      formData.value = {};
      Object.entries(props.detail || {}).forEach(([key, value]) => {
        formData.value[key] = value;
      });
    };
    const submit = async ({ value, done }) => {
      var _a;
      console.log(value);
      try {
        const id = (_a = props.detail) == null ? void 0 : _a.id;
        const api = id ? updateUser : addUser;
        await api({ user: { id: id || "", ...value, password2: void 0 } });
        done == null ? void 0 : done();
        visible.value = false;
        ElMessage({ type: "success", message: id ? "修改成功" : "新增成功" });
        emits("update");
      } catch {
        done == null ? void 0 : done();
      }
    };
    return (_ctx, _cache) => {
      const _component_XcForm = resolveComponent("XcForm");
      return openBlock(), createBlock(_component_XcForm, {
        ref_key: "formView",
        ref: formView,
        visible: visible.value,
        "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => visible.value = $event),
        state: state.value,
        closeReset: true,
        title: title.value,
        config: config2,
        values: formData.value,
        isDialog: "",
        colProps: 6,
        dialogWidth: 600,
        dialogHeight: 300,
        dialogMaximize: "",
        onOpen: init,
        onSubmit: submit
      }, null, 8, ["visible", "state", "title", "values"]);
    };
  }
});
const _hoisted_1 = { class: "list-view" };
const _hoisted_2 = { class: "filter-view" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...{
    name: "UserView",
    components: { AddDialog: _sfc_main$1 }
  },
  __name: "index",
  setup(__props, { expose: __expose }) {
    const dataEvent = (data) => {
      console.log("子组件收到数据了", data);
    };
    __expose({
      dataEvent
    });
    const userStore = useUserStore();
    console.log("存储后 Pinia 中的值：", userStore.sendUserCmd);
    const queryFormRef = ref();
    const query = ref({ pageIndex: 1, pageSize: 30, keyword: "", roleType: null });
    const state = ref("");
    const total = ref(0);
    const tableConfig = [
      { label: "用户ID", prop: "id", hidden: true },
      { label: "用户名", prop: "name" },
      { label: "账号", prop: "account" },
      { label: "角色", prop: "role" }
    ];
    const tableData = ref([]);
    const queryFilterConfig = [
      { placeholder: "关键字搜索", prop: "keyword", attrs: { suffixIcon: Search } },
      { placeholder: "请选择角色", prop: "roleType", type: "select", options: [] }
    ];
    const roles = ref([]);
    onMounted(() => {
      console.log("加载成功之后应该会触发这个函数");
      getRoleList();
      getList();
    });
    const getList = async () => {
      state.value = "loading";
      const {
        data: { list, total_Count }
      } = await getUsersByCondition(query.value);
      state.value = "";
      tableData.value = list || [];
      total.value = total_Count || 0;
    };
    const getRoleList = async () => {
      var _a;
      const { data } = await getRoles({});
      roles.value = (data || []).map((it) => ({ label: it, value: it }));
      (_a = queryFormRef.value) == null ? void 0 : _a.update("roleType", "options", roles.value);
    };
    let queryFilter = async ({ value, done }) => {
      query.value.pageIndex = 1;
      query.value = { ...query.value, ...value, roleType: value.roleType || null };
      await getList();
      done == null ? void 0 : done();
    };
    const detailModel = function useDetail() {
      const formDialogVisible = ref(false);
      const activeItem = ref();
      return {
        activeItem,
        formVisible: formDialogVisible,
        showForm: (item) => {
          activeItem.value = item;
          formDialogVisible.value = true;
        },
        onFormUpdate: getList
      };
    }();
    const onDelete = async (row) => {
      await ElMessageBox({
        title: "提示",
        message: `是否确定删除用户“${row.name}”?`,
        type: "warning",
        showCancelButton: true,
        beforeClose: async (action, instance, done) => {
          if (action === "confirm") {
            try {
              instance.confirmButtonLoading = true;
              instance.confirmButtonText = `执行中...`;
              await deleteUser({ userId: row.id });
              done();
            } catch {
              instance.confirmButtonText = `确定`;
            }
            instance.confirmButtonLoading = false;
          } else {
            done();
          }
        }
      });
      ElMessage.closeAll();
      ElMessage.success(`删除成功`);
      getList();
    };
    return (_ctx, _cache) => {
      const _component_el_link = resolveComponent("el-link");
      const _component_el_button = resolveComponent("el-button");
      const _component_XcForm = resolveComponent("XcForm");
      const _component_XcTable = resolveComponent("XcTable");
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(_component_XcTable, {
          class: "is-list",
          ref: "tableView",
          tableKey: _ctx.$route.path,
          keywords: query.value.keyword,
          "onUpdate:keywords": _cache[1] || (_cache[1] = ($event) => query.value.keyword = $event),
          page: query.value.pageIndex,
          "onUpdate:page": _cache[2] || (_cache[2] = ($event) => query.value.pageIndex = $event),
          limit: query.value.pageSize,
          "onUpdate:limit": _cache[3] || (_cache[3] = ($event) => query.value.pageSize = $event),
          pageTotal: total.value,
          config: tableConfig,
          state: state.value,
          values: tableData.value,
          formRef: queryFormRef.value,
          operationWidth: "180px",
          pagingConfig: { background: true },
          onUpdate: getList
        }, {
          default: withCtx(({ row }) => [
            createVNode(_component_el_link, {
              size: "small",
              type: "primary",
              underline: false,
              onClick: ($event) => unref(detailModel).showForm(row)
            }, {
              default: withCtx(() => [..._cache[5] || (_cache[5] = [
                createTextVNode("编辑", -1)
              ])]),
              _: 2
            }, 1032, ["onClick"]),
            row.account !== "admin" ? (openBlock(), createBlock(_component_el_link, {
              key: 0,
              size: "small",
              type: "danger",
              underline: false,
              onClick: ($event) => onDelete(row)
            }, {
              default: withCtx(() => [..._cache[6] || (_cache[6] = [
                createTextVNode("删除", -1)
              ])]),
              _: 2
            }, 1032, ["onClick"])) : createCommentVNode("", true)
          ]),
          actions: withCtx(() => [
            createElementVNode("div", _hoisted_2, [
              createVNode(_component_el_button, {
                type: "primary",
                icon: unref(Plus),
                onClick: _cache[0] || (_cache[0] = ($event) => unref(detailModel).showForm())
              }, {
                default: withCtx(() => [..._cache[7] || (_cache[7] = [
                  createTextVNode("新建用户", -1)
                ])]),
                _: 1
              }, 8, ["icon"]),
              createVNode(_component_XcForm, {
                config: queryFilterConfig,
                ref_key: "queryFormRef",
                ref: queryFormRef,
                isQueryFilter: "",
                onSubmit: unref(queryFilter)
              }, null, 8, ["onSubmit"])
            ])
          ]),
          _: 1
        }, 8, ["tableKey", "keywords", "page", "limit", "pageTotal", "state", "values", "formRef"]),
        createVNode(_sfc_main$1, {
          modelValue: unref(detailModel).formVisible.value,
          "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => unref(detailModel).formVisible.value = $event),
          detail: unref(detailModel).activeItem.value,
          roles: roles.value,
          onUpdate: unref(detailModel).onFormUpdate
        }, null, 8, ["modelValue", "detail", "roles", "onUpdate"])
      ]);
    };
  }
});
const _export_sfc = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const UserForm = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-3ac59145"]]);
const config = {
  moudleType: "UserForm",
  name: "用户模块",
  version: "1.0.0",
  description: "用户列表查询"
};
class UserModule {
  constructor(sendCmd, initialData = {}) {
    __publicField(this, "config", config);
    __publicField(this, "_eventData");
    __publicField(this, "sendCmd");
    this._eventData = ref(initialData);
    this.sendCmd = sendCmd;
  }
  sendCommand(cmd, cmdParams) {
    console.log("发送指令：", cmd, cmdParams);
    return this.sendCmd(this.config.moudleType, cmd, cmdParams);
  }
  install(app) {
    app.component("UserForm", UserForm);
    app.provide(GET_USER_DATA_KEY, () => this.eventData);
    app.provide(SEND_USER_CMD_KEY, (cmd, cmdParams) => {
      console.log("用户模块内部转发指令：", cmd, cmdParams);
      return this.sendCommand(cmd, cmdParams);
    });
  }
  get eventData() {
    return this._eventData;
  }
  dataEvent(data) {
    Object.assign(this._eventData, data);
  }
  async startup() {
    const userStore = useUserStore();
    if (!userStore.sendUserCmd) {
      console.log("Pinia 中未存储 sendUserCmd,进行存储");
      userStore.setInjections({
        sendUserCmd: (cmd, cmdParams) => this.sendCommand(cmd, cmdParams)
      });
    }
    console.log("插件根组件获取到 sendUserCmd,初始化成功", userStore.sendUserCmd);
    console.log("存储后 Pinia 中的值：", userStore.sendUserCmd);
    console.log("用户模块初始化完成");
  }
}
const createUserModule = (sendCmd, initialData) => {
  return new UserModule(sendCmd, initialData);
};
export {
  UserForm,
  createUserModule
};
